Skip to content

feat(supermassive): early execution and merge#680

Open
pavelglac wants to merge 20 commits into
mainfrom
user/pavelglac/defer
Open

feat(supermassive): early execution and merge#680
pavelglac wants to merge 20 commits into
mainfrom
user/pavelglac/defer

Conversation

@pavelglac

@pavelglac pavelglac commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Adds defer optimizations for Supermassive:

  • Early execution of deferred fragments, similar to GraphQL 17 behavior.
  • Merging resolved deferred patches into the initial response before sending it.
  • Optional timed batching for incremental patches, useful when a deferred fragment appears across many list items, to reduce the number of follow-up responses.

pavelglac and others added 15 commits June 22, 2026 09:20
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
const incremental = getCompletedIncrementalResults(exeContext);
const batchTimeout = exeContext.enableIncrementalPayloadBatching;
const incremental =
batchTimeout !== undefined

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot it should typeof check for number.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 50a55c2: switched the batching guards to runtime number checks (typeof batchTimeout === "number") before using the timeout value.

@pavelglac pavelglac changed the title early execution and merge feat(supermassive): early execution and merge Jul 14, 2026
@pavelglac pavelglac requested a review from Copilot July 14, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configurable optimizations to Supermassive’s incremental @defer execution to reduce perceived latency and reduce incremental payload churn, bringing behavior closer to GraphQL 17’s incremental execution.

Changes:

  • Adds execution flags for early deferred-fragment execution, merging completed deferred payloads into the initial response, and timed batching of incremental payload emission.
  • Implements deferred-fragment merge into the initial result (when possible) and optional timeout-based batching for subsequent incremental results.
  • Adds a getObjectAtPath helper plus a dedicated test suite covering merge + batching behaviors for executeWithSchema.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/supermassive/src/types.ts Adds new execution options controlling early defer execution, merge, and batching.
packages/supermassive/src/jsutils/getObjectAtPath.ts New helper to locate an object/assign-target at a response path for merge.
packages/supermassive/src/executeWithSchema.ts Plumbs new execution options through the schema-backed entrypoint.
packages/supermassive/src/executeWithoutSchema.ts Core implementation: early patch execution, merge-into-initial-response, and incremental batching logic.
packages/supermassive/src/tests/executeWithSchema.test.ts New tests covering merge behavior and batching behavior.
change/@graphitation-supermassive-8876a266-3c69-4f89-819b-4fc57b5b4470.json Changeset entry for the Supermassive minor release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 335 to 345
result = executeFields(
exeContext,
rootTypeName,
rootValue,
path,
groupedFieldSet,
undefined,
exeContext.enableEarlyExecution ? patches : undefined,
);
result = buildResponse(exeContext, result);
break;
Comment thread packages/supermassive/src/executeWithoutSchema.ts
Comment thread packages/supermassive/src/types.ts Outdated
Comment on lines +260 to +262
enableEarlyExecution?: boolean;
enableDeferredMerge?: boolean;
enableIncrementalPayloadBatching?: number;
Comment thread packages/supermassive/src/__tests__/executeWithSchema.test.ts
Comment thread packages/supermassive/src/__tests__/executeWithSchema.test.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants